﻿using UnityEngine;
using System.Collections;

namespace Room
{
    public class RCAIChariotStand : RCAIChariotBase
    {
        GameObject obj;
        protected override void OnEnter()
        {
            if(obj==null)
            {
                obj = controller.Spawn(RoomUnionFight.CHARIOT_STAND);
            }
            else
            {
                obj.SetActive(true);
            }
        }

        protected override void OnLeave()
        {
            if(obj!=null)
            {
                controller.Unspawn(obj);
                obj = null;
            }
        }

        protected override void OnTick()
        {
            if(controller.IamAniWeak)
            {
                if (!controller.owner.lod.IsPlayingAnim(ChariotAnimation.Stand))
                    controller.owner.PlayAnim(ChariotAnimation.Stand,WrapMode.Loop);
            }
            else
            {
                if (!controller.owner.lod.IsPlayingAnim(ChariotAnimation.StandWeak))
                    controller.owner.PlayAnim(ChariotAnimation.StandWeak, WrapMode.Loop);
            }
        }
    }
}